#!/usr/bin/make -f

REPO    := gosigar
WHOAMI  := themusicgod1
NOTABUG := notabug
# Required: Put the url (without http://) of your git repo.
export DH_GOPKG := notabug.org/$(WHOAMI)/$(REPO)

# Required: Put the name of your git repo below. 
GIT_REPO_NAME := $(NOTABUG)-$(WHOAMI)-$(REPO)
OUT1 := debian/golang-$(GIT_REPO_NAME)-dev/usr/lib/$(REPO)
# usr/gocode/src/notabug.org/$(WHOAMI)/$(REPO)/

BUILD_DIR := obj-$(DEB_HOST_GNU_TYPE)
export PATH := $(CURDIR)/$(BUILD_DIR)/bin:$(PATH)

##
# From git-lfs/git-lfs repo:
# by-default, dh_golang only copies *.go and other source - this upsets a bunch of vendor test routines
##
#export DH_GOLANG_INSTALL_ALL := 1

%:
	dh $@ --buildsystem=golang --with=golang



override_dh_auto_build:
	dh_auto_build -- -ldflags "-s -w"
	##
	# From git-lfs/git-lfs repo:
	# dh_golang doesn't do anything here in deb 8, and it's needed in both
	##
## ??
	if [ "$(DEB_HOST_GNU_TYPE)" != "$(DEB_BUILD_GNU_TYPE)" ]; then\
		cp -rf $(BUILD_DIR)/bin/*/* $(BUILD_DIR)/bin/; \
#		cp -rf $(BUILD_DIR)/pkg/*/* $(BUILD_DIR)/pkg/; \
	fi

override_dh_auto_install:

	# golang-notabug-themusicgod1-panicparse-dev
	# This is making a "fakeroot" so that when the deb is installed the binary will be placed in /usr/bin.
#	mkdir -p debian/golang-$(GIT_REPO_NAME)-dev/usr/bin
	mkdir -p $(OUT1)
	mkdir -p $(OUT1)/examples
#	mkdir -p $(OUT1)/pkg
	mkdir -p $(OUT1)/src/gosigar

	# This is copying the binary and placing it in the fake root path.
	cp $(BUILD_DIR)/bin/df $(OUT1)/examples
	cp $(BUILD_DIR)/bin/free $(OUT1)/examples
	cp $(BUILD_DIR)/bin/ps $(OUT1)/examples
	cp $(BUILD_DIR)/bin/ss $(OUT1)/examples
	cp $(BUILD_DIR)/bin/uptime $(OUT1)/examples
#	cp -r $(BUILD_DIR)/pkg/* $(OUT1)/pkg
	cp -r $(BUILD_DIR)/src/* $(OUT1)/src
